<div id="sub_nav">
      <p>Quick Links:</p>
      <ul>
        <li><a href="javascript:void(0);" title="Add Category" controller="add_category" action="index" onclick="showPop(this)">Add Category</a></li>
        <li><a href="javascript:void(0);" title="Global Brand" controller="global_brand" action="index" ElmID="brand" onclick="showPop(this)">Global Brands</a></li>
        <li><a href="javascript:void(0);" title="Global Styles" controller="global_brand" action="index" ElmID="style" onclick="showPop(this)">Global Styles</a></li>
        <li><a href="javascript:void(0);" title="Global Conditions" controller="global_brand" action="index" ElmID="condition" onclick="showPop(this)">Global Conditions</a></li>
        <!--li><a href="javascript:void(0);" title="Shipping Methods" controller="shippings" action="addshipping" onclick="showPop(this)">Shipping Methods</a></li-->
      </ul>
    </div>

	<?php echo $this->element('admin/admin_leftmenu'); ?>

    <div id="left"> 
	  <?php echo $this->Session->flash(); ?>
		<div class="div_header"><?php __('Manage Category');?>
			<span style="margin-left: 445px;">
				<a style="color:#fff;text-decoration:none;" href="<?php echo Configure::read('base_url');?>backstage/manage_category/categoryatglance" target="_blank">Category at a Glance</a>
			</span>
		</div>
      <div class="div_content">
        <table id="category_table" cellspacing="0" class="tablesorter">
		<thead>
          <tr>
            <th width="50"><?php echo _('id');?></th>
            <th width="120"><?php echo _('Category Name');?></th>
            <th width="392">Category Specifications</th>
            <th width="60">Actions</th>
            <th width="60">Order</th>
            <th>&nbsp;</th>
          </tr>
		  </thead>
		  <tbody> 
		  <?php
			$i = 0;
			//pr($category);
			foreach ($categories as $cat):
				$class = null;
				if ($i++ % 2 == 0)
					$class = ' class="alt"';
				
			?>
          <tr>
            <td <?php echo $class;?>><?php echo $cat['Category']['id'];?></td>
            <td <?php echo $class;?>><?php echo $cat['Category']['category_name'];?></td>
            <td <?php echo $class;?>>
				<a href="javascript:void(0);" title="Edit Global Brands for <?php echo $cat['Category']['category_name'];?>" controller="categorybrands" action="index" ElmID="brand" ElmID2="<?php echo $cat['Category']['id'];?>"  onclick="showPop(this)" class="user_links">Brands(<?php echo $this->requestAction('/manage_category/total_brands/'.$cat['Category']['id']);?>)</a> | 
				<a href="javascript:void(0);" title="Edit Global Styles for <?php echo $cat['Category']['category_name'];?>" controller="categorybrands" action="index" ElmID="style" ElmID2="<?php echo $cat['Category']['id'];?>"  onclick="showPop(this)">Styles(<?php echo $this->requestAction('/manage_category/total_styles/'.$cat['Category']['id']);?>)</a> | 
				<a href="javascript:void(0);" title="Edit Global Conditions for <?php echo $cat['Category']['category_name'];?>" controller="categorybrands" action="index" ElmID="condition" ElmID2="<?php echo $cat['Category']['id'];?>"  onclick="showPop(this)">Conditions(<?php echo $this->requestAction('/manage_category/total_conditions/'.$cat['Category']['id']);?>)</a> | 
				<a href="javascript:void(0);" title="Sizes for <?php echo $cat['Category']['category_name'];?>" controller="add_category" action="sizes" ElmID="<?php echo $cat['Category']['id'];?>"  onclick="showPop(this)">Sizes(<?php echo $this->requestAction('/manage_category/total_sizes/'.$cat['Category']['id']);?>)</a> | 
				<a href="javascript:void(0);" title="Shipping Cost for <?php echo $cat['Category']['category_name'];?>" controller="shippings" action="index" ElmID="<?php echo $cat['Category']['id'];?>"  onclick="showPop(this)">Shipping Cost</a> | 
				<a href="javascript:void(0);" title="Additional fields for <?php echo $cat['Category']['category_name'];?>" controller="add_category" action="fields" ElmID="<?php echo $cat['Category']['id'];?>"  onclick="showPop(this)">Additional Fields(<?php echo $this->requestAction('/manage_category/total_additional_fields/'.$cat['Category']['id']);?>)</a> | 
				<a href="javascript:void(0);" title="Image title for <?php echo $cat['Category']['category_name'];?>" controller="add_category" action="imagetitle" ElmID="<?php echo $cat['Category']['id'];?>"  onclick="showPop(this)">Images(<?php echo $this->requestAction('/manage_category/total_imagetitles/'.$cat['Category']['id']);?>)</a> | 
				<a href="<?php echo Configure::read('base_url');?>backstage/manage_category/subcategories/<?php echo $cat['Category']['id'];?>">Subcategories(<?php echo $this->requestAction('/manage_category/total_subcategories/'.$cat['Category']['id']);?>)</a></td>
            <td align="center" <?php echo $class;?> class="iconImage">
				<a href="javascript:void(0);" controller="add_category" action="edit" title="Edit" ElmID="<?php echo $cat['Category']['id'];?>" onclick='showPop(this)'>
				<?php echo $this->Html->image("edit_gray.png", array("alt" => "Edit", 'border'=>'0'));?>
				</a>&nbsp;&nbsp;				
				<a href="javascript:void(0);" onclick="return showPop(this)" controller="manage_category" action='delete' ElmID="<?php echo $cat['Category']['id'];?>" title="<?php echo sprintf(__('Are you sure you want to delete %s?', true), $cat['Category']['category_name']);?>">
				<?php echo $this->Html->image("delete_gray.png", array("alt" => "Delete", 'border'=>'0'));
				?></a>
			</td>
			<td <?php echo $class;?>>
			<select name="reeorder_row_<?php echo $cat['Category']['id'];?>" class="select" onchange="location.href='<?php echo Configure::read('base_url');?>backstage/manage_category/updateorder/<?php echo $cat['Category']['id'];?>/'+this.value">
			<?php 
			foreach ($category_orders as $key=>$val):
			    $trimmed_val = ltrim($val, '0');
				if($val==$cat['Category']['category_order'])
					$selected=" selected='selected'";
				else	
					$selected="";
				echo'<option value="'.$trimmed_val.'" '.$selected.'>'.$trimmed_val.'</option>';
				endforeach;
			?>			
			</select>
			</td>
            <td align="center"  <?php echo $class;?> class="sort-handle">				
				<?php echo $this->Html->image("sort.png", array("alt" => "Sort",'border'=>'0'));?>				
			</td>
          </tr>
		 
		  <?php endforeach; ?>
		  </tbody> 
        </table>
      </div>
      <div class="div_bottom"></div>
    </div>    
    <!-- edit sidebar items here -->     
  </div>
<?php  echo $html->script(array("jquery.pagination.js","jquery.tablesorter.min.js","jquery.tablednd.js")); ?>	 
 <script type="text/javascript">  
 jQuery(document).ready(function(){
 jQuery("#category_table").tablesorter({headers: { 2:{sorter: false},3:{sorter: false}, 4:{sorter: false}, 5:{sorter: false}},sortList: [[0,0]]}); 
 });	
 </script>
  <style type="text/css">
    .iconImage{width: 68px;}
  </style>